class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        //二分法查找
        int left=0,right=nums.size()-1;
        int sum=0;
        //遍历查找
        while(left<right){
            sum=nums[right]+nums[left];
            if(sum==target){
                return {nums[left],nums[right]};
            }else if(sum>target){
                right--;
            }else{
                left++;
            }
        }
        return {};
    }
};